package com.xyh.flowershop.enums;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * @author 小约翰可汗
 * @className GenderEnum
 * @createTime 2024/5/210:32
 */
@Getter
public enum GenderEnum {

    WOMAN("女",0),
    MAN("男",1),
    UNKNOWN("未知",2);

    private final static Map<String, GenderEnum> keyMap = new HashMap<>();

    static {
        for(GenderEnum genderEnum : GenderEnum.values()){
            keyMap.put(genderEnum.genderInfo, genderEnum);
        }
    }

    public static GenderEnum fromInfo(String info){
        GenderEnum genderEnum = keyMap.get(info);
        if(Objects.isNull(genderEnum)){
            return UNKNOWN;
        }
        return genderEnum;
    }

    private Integer genderCode;

    private String genderInfo;


    GenderEnum(String genderInfo,Integer genderCode) {
        this.genderCode = genderCode;
        this.genderInfo = genderInfo;
    }

}
